<template>
    <div id="">
        <button @click="flag = !flag">切换</button>
        <!-- 切换发现组件里的值还是会被保留的 -->
        <keep-alive>
            <Login v-if="flag"></Login>
            <Register v-else></Register>
        </keep-alive>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Login from '../login/index.vue';
import Register from '../register/index.vue';

const flag = ref<boolean>(true)
</script>

<style lang="less" scoped>
</style>
